Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 19, 2026

Implementation Plan for Single PHP Plugin File Installation

  • Understand current implementation and test structure
  • Add detection for single PHP file URLs in CommandWithUpgrade.php
  • Add logic to download and save single PHP files to plugins directory
  • Handle plugin naming from single PHP files
  • Add Behat tests for single PHP plugin file installation
  • Add test for --force flag with PHP files
  • Update documentation in Plugin_Command
  • Address code review feedback (extract helper method, sanitize URLs, validate extension)
  • Add security validations (path traversal protection, early filename validation)
  • Improve UX (show download message before downloading)
  • Fix security issues (proper path validation, require valid plugin headers)
  • Ensure plugin directory exists before validation
  • All static analysis checks pass
  • Add support for GitHub Gist page URLs (gist.github.com format)
    • Detect gist.github.com URLs and extract gist ID
    • Fetch gist metadata from GitHub API
    • Find first PHP file in the gist
    • Convert to raw URL and proceed with installation
    • Add test for gist page URL format
  • Improve error handling and validation
    • Add specific error handling for HTTP codes (401, 500, 503)
    • Add null check before calling build_rate_limiting_error_message()
    • Verify directory creation after wp_mkdir_p()
    • Fix regex to properly match uppercase hex digits in gist IDs
  • Support anonymous gists
    • Make username optional in gist URL regex to support anonymous gists
  • Case-insensitive extension checks
    • Convert extensions to lowercase in all PHP extension validations
  • Ready for final review
Original prompt

This section details on the original issue you should resolve

<issue_title>Links to single plugin PHP file should work with plugin install</issue_title>
<issue_description>When using wp plugin install <URL>, WP-CLI currently assumes that the URL is pointing to a ZIP file of a plugin.

This command should also work with a URL to a single PHP plugin file, so that it can for example directly install plugins from GitHub Gists:

Example of such a command that should just work:

wp plugin install --activate https://gist.githubusercontent.com/westonruter/dec7d190060732e29a09751ab99cc549/raw/d55866c2fc82ab16f8909ce73fc89986ab28d727/pwa-manifest-short-name.php

/cc @westonruter (whose numerous Gist plugins make me want to implement the above)</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 6 commits January 19, 2026 10:08
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…oad message timing

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…plugin headers

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
…dation

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for installing plugins from PHP file URLs Support installing plugins from single PHP file URLs Jan 19, 2026
Copilot AI requested a review from swissspidy January 19, 2026 10:20
@github-actions github-actions bot added command:plugin-install Related to 'plugin install' command scope:testing Related to testing labels Jan 19, 2026
@swissspidy
Copy link
Member

@copilot Make sure wp plugin install --activate https://gist.github.com/westonruter/dec7d190060732e29a09751ab99cc549 works too and add a test for that

@codecov
Copy link

codecov bot commented Jan 19, 2026

Codecov Report

❌ Patch coverage is 61.90476% with 48 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/WP_CLI/CommandWithUpgrade.php 61.90% 48 Missing ⚠️

📢 Thoughts on this report? Let us know!

@swissspidy

This comment was marked as resolved.

@swissspidy

This comment was marked as resolved.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>

This comment was marked as resolved.

This comment was marked as resolved.

swissspidy and others added 3 commits January 19, 2026 17:18
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@swissspidy swissspidy requested a review from Copilot January 19, 2026 17:05
@swissspidy

This comment was marked as resolved.

gemini-code-assist[bot]

This comment was marked as resolved.

This comment was marked as resolved.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- Add specific error handling for HTTP codes 401, 500, 503
- Add fallback for malformed rate limit responses
- Verify plugin directory creation after wp_mkdir_p()
- Fix regex pattern to properly match uppercase hex in gist IDs
- Add catch-all for unexpected HTTP status codes

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Anonymous gists don't have a username in the URL path (e.g.,
gist.github.com/1234567890abcdef). Updated regex to make the username
segment optional using non-capturing group (?:[^/]+/)? so both
user-owned and anonymous gists are supported.

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
Convert extension to lowercase before comparison in all PHP extension
checks to handle files with uppercase extensions (e.g., .PHP, .Php).
This makes the validation more robust and consistent across:
- Sanitized filename validation
- URL path detection
- Gist file filtering

Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com>
}

// Find PHP files in the gist
$php_files = [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we use short array syntax in WP-CLI?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes!

@swissspidy swissspidy marked this pull request as ready for review January 22, 2026 12:44
@swissspidy swissspidy requested a review from a team as a code owner January 22, 2026 12:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

command:plugin-install Related to 'plugin install' command scope:testing Related to testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Links to single plugin PHP file should work with plugin install

3 participants